# encoding=utf-8

import socket
from conf import modules


class ModuleInterface(object):
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

    @classmethod
    def call(self, name, req_body):
        for module in modules:
            if module["name"] == name:
                ModuleInterface.sock.sendto(req_body, ("127.0.0.1", module["udp-port"]))
                break
